package com.kd.juhaowan.ui;

import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.util.Log;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.kd.juhaowan.R;

import butterknife.BindView;
import butterknife.OnClick;

public class SettingActivity extends BaseActivity {





    @BindView(R.id.activity_title)
    TextView titleView;
    @BindView(R.id.setting_version)
    TextView versionView;


    @Override
    protected void reInitDate() {

    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        titleView.setText("设置中心");

        try {
            PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
            String versionName = packageInfo.versionName;
            versionView.setText("版本：V"+versionName);
            // 输出版本名称
            Log.d("MainActivity", "Version Name: " + versionName);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
//        setContentView(R.layout.activity_account_login);

    }
    @OnClick(R.id.actvity_back)
    public void onBackClick(){
        finish();
    }
    @OnClick(R.id.setting_feedback)
    public void onFeedBackClick(){
        startActivity(new Intent(this,FeedBackActivity.class));
    }
    @OnClick(R.id.setting_accountManager)
    public void onAccountManagerClick(){
        startActivity(new Intent(this,AccountManagerActivity.class));
    }
    @OnClick(R.id.setting_private)
    public void onPrivateClick(){
        startActivity(new Intent(this,SettingPrivateActivity.class));
    }
    @OnClick(R.id.setting_permission)
    public void onPermissionClick(){
        Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        Uri uri = Uri.fromParts("package", getPackageName(), null);
        intent.setData(uri);
        startActivity(intent);

//        new JumpPermissionManagement(getApplication()).jumpPermissionPage();
    }
    @OnClick(R.id.setting_logout)
    public void onLogoutClick(){
        manager.writeAutoLogin(false);
        manager.saveCurrentLoginUserTickit("");
        Intent intent = new Intent(this,LoginAccountActivity.class);
        intent.putExtra("isLogout",true);
        startActivity(intent);
        finish();
    }

    @Override
    protected int getViewLayoutResourceId() {
        return R.layout.activity_setting;
    }




}
